import requestMeeting, { request } from '@/plugins/axios'
import {
	ErrorEntity,
	FetchStylesByMeetingMoidDetailResponseEntity,
	FetchStylesByMeetingMoidResponseEntity,
	FetchTvwallStylesResponseEntity,
	PlanDetailEntity,
	PlanResponseEntity,
	StyleDetail,
	VolumeEntity,
} from './interface'
/**
 * 相当于旧接口:tvWall/loadTVWall
 * @param meeting_id 会议的meetingMoid
 * @returns 电视墙风格列表
 */
export const fetchGetAllTvwallStyles = async () =>
	requestMeeting<FetchTvwallStylesResponseEntity>({
		url: `/tvwall_styles`,
		method: 'GET',
		params: {
			start: 0,
			count: 0,
			position: 1,
			order: 0,
		},
	}).then((res) => res)
/**
 *
 * @param meeting_id 会议的meetingMoid
 * @returns 获取会议的电视墙风格列表
 */
export const fetchGetStylesByMeetingMoidInfo = async (meeting_id: string) =>
	requestMeeting<FetchStylesByMeetingMoidResponseEntity>({
		url: `/mcc/${meeting_id}/tvwalls/styles`,
		method: 'GET',
	}).then((res) => res)
/**
 *
 * @param meeting_id 会议的meetingMoid
 * @returns 获取会议全部风格详情数据
 */
export const fetchGetStylesByMeetingMoidStyleInfo = async (meeting_id: string) =>
	requestMeeting<FetchStylesByMeetingMoidDetailResponseEntity>({
		url: `/mcc/${meeting_id}/tvwalls/styles/all`,
		method: 'GET',
	}).then((res) => res)
/**
 *
 * @param meeting_id 会议的meetingMoid
 * @param style_id 电视墙风格 id [Path参数]
 * @returns 获取会议的电视墙风格详情
 */
export const fetchGetStylesDetailInfo = async (meeting_id: string, style_id: string) =>
	requestMeeting<StyleDetail>({
		url: `/mcc/${meeting_id}/tvwalls/styles/${style_id}`,
		method: 'GET',
	}).then((res) => res)
/************************************************电视墙风格***************************************************** */
/**删除电视墙风格 */
export const fetchDelTvWallStyle = async (
	meeting_id: string,
	styles: { styles: Array<{ id: string; name: string }> }
) =>
	requestMeeting({
		url: `/mcc/${meeting_id}/tvwalls/styles`,
		method: 'DELETE',
		data: styles,
	}).then((res) => res.success)
/**新增电视墙风格 */
export const fetchAddTvWallStyle = async (
	meeting_id: string,
	styles: { styles: Array<{ id: string; name: string }> }
) =>
	requestMeeting({
		url: `/mcc/${meeting_id}/tvwalls/styles`,
		method: 'POST',
		data: styles,
	}).then((res) => res.success)
/***************************************************电视墙预案**************************************** */
/**获取*/
export const fetchGetTvWallPlanList = async (meetingMoid: string) =>
	requestMeeting<PlanResponseEntity>({
		url: `/meetings/${meetingMoid}/pretvwalls?count=0`,
		method: 'GET',
	}).then((res) => res)
/**详情*/
export const fetchTVWallPlanDetail = async (meeting_id: string, id: string) =>
	request<PlanDetailEntity | ErrorEntity>({
		url: `/meetings/${meeting_id}/pretvwalls/${id}?type=1`,
		method: 'GET',
	}).then((res) => res)
/**删除*/
export const fetchDelTVWallPlan = async (meeting_id: string, id: string) =>
	requestMeeting({
		url: `/meetings/${meeting_id}/pretvwalls/${id}`,
		method: 'DELETE',
	}).then((res) => res)
/**新增*/
export const fetchAddTvWallPlan = async (meeting_id: string, params: any) =>
	requestMeeting<PlanResponseEntity>({
		url: `/meetings/${meeting_id}/pretvwalls`,
		method: 'POST',
		data: params,
	}).then((res) => res)
/**更新 */
export const fetchUpdateTVWallPlan = async (meeting_id: string, id: string, params: any) =>
	requestMeeting({
		url: `/meetings/${meeting_id}/pretvwalls/${id}`,
		method: 'POST',
		data: params,
	}).then((res) => res)
/**发送预案改变请求*/
export const fetchChangeTVWallPlan = async (meeting_id: string, params: {}) =>
	requestMeeting({
		url: `/mcc/${meeting_id}/tvwalls`,
		method: 'POST',
		data: params,
	}).then((res) => res)
/********************************************************************************终端名称显示************************************************ */
/**切换会议当前电视墙终端别名显示模式*/
export const fetchChangeIfShowMTName = async (meeting_id: string, style_id: string, show_mt_name: number) =>
	requestMeeting({
		url: `/mcc/${meeting_id}/tvwalls/styles/${style_id}/alias`,
		method: 'PUT',
		data: { show_mt_name: show_mt_name },
	}).then((res) => res)
/**切换会议当前电视墙终端别名显示模式*/
export const fetchGetMTChnInfo = async (meeting_id: string, mt_id: string) =>
	request<{
		list: {
			a_snd_chn_id: number
			v_snd_chn_id: number
		}[]
	}>({
		url: `/mcc/${meeting_id}/mts/${mt_id}/chn_info`,
		method: 'GET',
	}).then((res) => res)
/*************************************************************轮询预案********************************************* */
export const fetchGetPollPlanList = async (meetingMoid: string) =>
	requestMeeting<PlanResponseEntity>({
		url: `/meetings/${meetingMoid}/prepolls?count=0`,
		method: 'GET',
	}).then((res) => res)
/********************************************************************开始批量轮询/停止批量轮询********************************************************************** */
/**修改会议的电视墙风格信息*/
export const fetchChnageStyleInfo = async (meeting_id: string, style_id: string, data: any) =>
	requestMeeting({
		url: `/mcc/${meeting_id}/tvwalls/styles/${style_id}/info`,
		method: 'PUT',
		data: data,
	}).then((res) => res)
// /**
//  *
//  * @param meeting_id
//  * @returns {t('获取会议混音预案信息列表')}
//  */
// export const fetchGetPlanDetail = async (meeting_id: string, mix_id: string) =>
// 	request<PlanResponsePollEntity>({
// 		url: `/meetings/${meeting_id}/premixs/${mix_id}?type=1`,
// 		method: 'GET',
// 	}).then((res) => res)
// /**
//  *
//  * @param meetingMoid {t('会议的')}meetingMoid
//  * @param value {t('预案名称')}
//  * @returns {t('删除预案')}
//  */
// export const fetchDeletePlan = async (meetingMoid: string, value: string) =>
// 	requestMeeting({
// 		url: `/meetings/${meetingMoid}/premixs/${value}`,
// 		method: 'DELETE',
// 	}).then((res) => res)
// /**
//  *
//  * @param meetingMoid {t('会议的')}meetingMoid
//  * @param value {t('预案名称')}
//  * @returns {t('新增预案')}
//  */
// export const fetchAddPlan = async (meetingMoid: string, plan_data: any) =>
// 	requestMeeting({
// 		url: `/meetings/${meetingMoid}/premixs`,
// 		method: 'POST',
// 		data: JSON.stringify(plan_data),
// 	}).then((res) => res)
// /**
//  *
//  * @param meetingMoid {t('会议的')}meetingMoid
//  * @param value {t('预案名称')}
//  * @returns {t('更新预案')}
//  */
// export const fetchUpdatePlan = async (meetingMoid: string, id: string, plan_data: any) =>
// 	requestMeeting({
// 		url: `/meetings/${meetingMoid}/premixs/${id}`,
// 		method: 'POST',
// 		data: JSON.stringify(plan_data),
// 	}).then((res) => res)
/*****************************************************************************HDU音量***************************************/
/**获取会议的电视墙通道信息 */
export const fetchGetHduVolume = async (meeting_id: string, hdu_id: string) =>
	requestMeeting<VolumeEntity>({
		url: `/mcc/${meeting_id}/tvwalls/channels/${hdu_id}/info`,
		method: 'GET',
	}).then((res) => res)
/**修改会议的电视墙通道信息 */
export const fetchSetHduVolume = async (
	meeting_id: string,
	hdu_id: string,
	_data: { silence: number; volume: number }
) =>
	requestMeeting({
		url: `/mcc/${meeting_id}/tvwalls/channels/${hdu_id}/info`,
		method: 'PUT',
		data: _data,
	}).then((res) => res)
